import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from "@/views/Home.vue";
import Main from "@/views/page/Main.vue";
import Login from "@/views/user/Login.vue";
import Center from "@/views/page/Center.vue";
import register from "@/views/user/Register.vue";
import Manage from "@/views/admin/page/Manage.vue";
import AdminLogin from "@/views/admin/AdminLogin.vue";
import Collection from "@/views/admin/page/manage/Collection.vue"
import Notice from "@/views/page/notice.vue";
import addNotice from "@/views/admin/page/manage/AddNotice.vue";
import Exhibit from "@/views/page/Exhibit.vue";
import AddExhibit from "@/views/admin/page/manage/AddExhibit.vue";
import Booking from "@/views/page/Booking.vue";
import ShowNotice from "@/views/admin/page/manage/ShowNotice.vue";
import ShowExhibit from "@/views/admin/page/manage/ShowExhibit.vue";
import ShowStaff from "@/views/admin/page/manage/Staff.vue";
import Department from "@/views/admin/page/manage/Department.vue";
import Mission from "@/views/admin/page/manage/Mission.vue";
import InternalNotice from "@/views/admin/page/manage/InternalNotice.vue";
import Functions from "@/views/admin/page/manage/Functions.vue";
import ShowMission from "@/views/admin/page/manage/ShowMission.vue";

Vue.use(VueRouter)

const routes = [
    {
        path: '/', component: Home, redirect: '/main',
        children: [
            {path: '/main', component: Main, meta: {title: '博物院'}},
            {path: '/notice', component: Notice, meta: {title: '公告'}},
            {path: '/exhibit', component: Exhibit, meta: {title: '展览'}},
            {path: '/booking', component: Booking, meta: {title: '预约'}},
        ],
    },
    {path: '/login', component: Login, meta: {title: '登录页'}},
    {path: '/center', component: Center, meta: {title: '个人中心'}},
    {path: '/register', component: register, meta: {title: '注册页'}},
    {
        path: '/admin', component: Manage, redirect: '/admin/mission/get',
        children: [
            {path: '/admin/personnel', component: ShowStaff, meta: {title: '人事管理'}},
            {path: '/admin/collection', component: Collection, meta: {title: '藏品管理'}},
            {path: '/admin/exhibit/get', component: ShowExhibit, meta: {title: '展览管理'}},
            {path: '/admin/exhibit/add', component: AddExhibit, meta: {title: '发布管理'}},
            {path: '/admin/notice/get', component: ShowNotice, meta: {title: '公告管理'}},
            {path: '/admin/notice/add', component: addNotice, meta: {title: '发布公告'}},
            {path: '/admin/department', component: Department, meta: {title: '部门管理'}},
            {path: '/admin/mission', component: Mission, meta: {title: '任务管理'}},
            {path: '/admin/internal/notice', component: InternalNotice, meta: {title: '通知管理'}},
            {path: '/admin/functions', component: Functions, meta: {title: '职能管理'}},
            {path: '/admin/mission/get', component: ShowMission, meta: {title: '查看任务'}},
        ],
    },
    {path: '/admin/login', component: AdminLogin, meta: {title: '管理登录'}},
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

router.afterEach((to, from) => {
    document.title = to.meta.title //在全局后置守卫中获取路由元信息设置title

})

export default router
